package com.huishi.enums;

import lombok.Getter;

@Getter
public enum TimeUnit {
    SECONDS(0, "秒"),
    MINUTES(1, "分钟"),
    HOURS(2, "小时"),
    DAYS(3, "天"),
    WEEKS(4, "周"),
    MONTHS(5, "月");

    private final int value;
    private final String unit;

    TimeUnit(int value, String unit) {
        this.value = value;
        this.unit = unit;
    }

    public static String[] getAllUnits() {
        return new String[] {
                SECONDS.getUnit(),
                MINUTES.getUnit(),
                HOURS.getUnit(),
                DAYS.getUnit(),
                WEEKS.getUnit(),
                MONTHS.getUnit()
        };
    }

    public static int getValueByUnit(String unit) {
        for (TimeUnit timeUnit : TimeUnit.values()) {
            if (timeUnit.getUnit().equals(unit)) return timeUnit.getValue();
        }
        return 0;
    }
}

